package Ioperation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Return implements Ioperate{
    @Override
    public void operate(BookList bookList) {
        System.out.println("请输入你要归还书名：");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();

        int count = bookList.getCurSize();
        for (int i = 0; i < count; i++) {
            Book book = bookList.getBooks(i);
            if(book.getName().equals(name)){
                if(book.isIs_borrowed() == true){
                    System.out.println("归还成功......");
                    book.setIs_borrowed(false);
                }else{
                    System.out.println("该图书已被归还到书架上，无需重复归还......");
                }
                return;
            }
        }

        System.out.println("未查询到该图书.....");
    }
}
